package com.netease.yanxuan.qa.yx.yuheng.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.env.Environment;

/**
 * 提供系统环境相关的接口方法
 * 
 * @author hzdengwei
 */
@Configuration
public class SystemEnvironmentConfig {

    public static final String DEV_ENVIRONMENT = "dev";

    public static final String TEST_ENVIRONMENT = "test";

    public static final String REGRESSION_ENVIRONMENT = "regression";

    public static final String RELEASE_ENVIRONMENT = "release";

    public static final String PRESSURE_ENVIRONMENT = "pressure";

    public static final String ONLINE_ENVIRONMENT = "online";

    @Autowired
    private Environment environment;

    /**
     * 判断系统当前环境是否是开发环境
     * 
     * @return
     */
    public boolean isDevEnvironment() {

        return environment.acceptsProfiles(DEV_ENVIRONMENT);
    }

    /**
     * 判断系统当前环境是否是测试环境
     * 
     * @return
     */
    public boolean isTestEnvironment() {
        return environment.acceptsProfiles(TEST_ENVIRONMENT);
    }

    /**
     * 判断系统当前环境是否是回归环境
     *
     * @return
     */
    public boolean isRegressionEnvironment() {
        return environment.acceptsProfiles(REGRESSION_ENVIRONMENT);
    }

    /**
     * 判断系统当前环境是否是预发布环境
     * 
     * @return
     */
    public boolean isReleaseEnvironment() {
        return environment.acceptsProfiles(RELEASE_ENVIRONMENT);
    }

    /**
     * 判断系统当前环境是否是压测环境
     *
     * @return
     */
    public boolean isPressureEnvironment() {
        return environment.acceptsProfiles(PRESSURE_ENVIRONMENT);
    }

    /**
     * 判断系统当前环境是否是线上环境
     * 
     * @return
     */
    public boolean isOnlineEnvironment() {
        return environment.acceptsProfiles(ONLINE_ENVIRONMENT);
    }

}
